//
//  SettingViewController.m
//  quickBatchManager
//
//  Created by 王定波 on 15/9/29.
//  Copyright © 2015年 jack. All rights reserved.
//

#import "SettingViewController.h"

@interface SettingViewController ()
{
    NSArray *menuItems;
    UISwitch *bossswitch;
}

@end

@implementation SettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

-(void)initData
{
  //  menuItems=@[@"套账设置",@"老板模式",@"单号重置",@"付款方式",@"店员链接",@"密码修改",@"云备份",@"云同步",@"老板绑定",@"关于我们"];
     menuItems=@[@"付款方式",@"密码修改",@"云备份",@"云同步",@"关于我们"];
}


-(void)initUI
{
    UIImage *image = [UIImage imageNamed:@"setbag"];
    image = [image stretchableImageWithLeftCapWidth:floorf(image.size.width/2) topCapHeight:floorf(image.size.height/2)];
    _bg.image=image;
    _tableView.backgroundColor=[UIColor clearColor];
    self.view.backgroundColor=[UIColor clearColor];
    bossswitch=[[UISwitch alloc] init];
    
     self.view.frame=CGRectMake(0, 0, SCREEN_WIDTH/2, SCREEN_HEIGHT);
    
    
    [self addNavBack];
}

#pragma tableView delegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [menuItems count];
}


-(void)back
{
    self.splitViewController.tabBarController.selectedIndex=0;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    NSString *title=[menuItems objectAtIndex:indexPath.row];
    NSMutableArray *navarray=[[NSMutableArray alloc] init];
    [navarray addObject:[self.splitViewController.viewControllers objectAtIndex:0] ];
    if([title isEqualToString:@"单号重置"])
    {
        OrderNoResetViewController *handVc=[[OrderNoResetViewController alloc] init];
        [navarray addObject:handVc];
        self.splitViewController.viewControllers=navarray;
    }
    if([title isEqualToString:@"套账设置"])
    {
        TzSettingViewController *handVc=[[TzSettingViewController alloc] init];
        [navarray addObject:handVc];
        self.splitViewController.viewControllers=navarray;
    }
    
    else if([title isEqualToString:@"付款方式"])
    {
        PaymentViewController *handVc=[[PaymentViewController alloc] init];
        [navarray addObject:handVc];
        self.splitViewController.viewControllers=navarray;
    }
    
    else if([title isEqualToString:@"密码修改"])
    {
        GesturePasswordController *gpc=[[GesturePasswordController alloc] init];
      //  gpc.modalPresentationStyle=UIModalPresentationFormSheet;
      //  gpc.delegate=self;
        gpc.isChange=YES;
        BaseNavigationController *nav=[[BaseNavigationController alloc] initWithRootViewController:gpc];
        nav.view.backgroundColor=[UIColor clearColor];
        nav.modalPresentationStyle = UIModalPresentationFormSheet;
        nav.isGesturePassword=YES;
        self.definesPresentationContext = YES;
        [self presentViewController:nav animated:YES completion:nil];
    }
    
    else if([title isEqualToString:@"店员链接"])
    {
        ClerkContactController *handVc=[[ClerkContactController alloc] init];
        [navarray addObject:handVc];
        self.splitViewController.viewControllers=navarray;
    }
    
    else if([title isEqualToString:@"老板绑定"])
    {
        BossBindViewController *handVc=[[BossBindViewController alloc] init];
        [navarray addObject:handVc];
        self.splitViewController.viewControllers=navarray;
    }
    else if([title isEqualToString:@"关于我们"])
    {
        AboutUsController *handVc=[[AboutUsController alloc] init];
        [navarray addObject:handVc];
        self.splitViewController.viewControllers=navarray;
    } else if([title isEqualToString:@"云同步"])
    {
        SyncViewController *syncVC = [[SyncViewController alloc] init];
        [navarray addObject:syncVC];
        self.splitViewController.viewControllers=navarray;
    }
    else if([title isEqualToString:@"云备份"])
    {
        BackupViewController *backupVC = [[BackupViewController alloc] init];
        [navarray addObject:backupVC];
        self.splitViewController.viewControllers=navarray;
    }
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    NSString *reuseIdetify = @"tablecell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdetify];
    if(!cell){
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdetify];
    }
    NSString *title=[menuItems objectAtIndex:indexPath.row];
    cell.textLabel.text =title;
    [cell.textLabel setFont:[UIFont fontWithName:FontWord size:15]];
    cell.textLabel.textColor=[UIColor darkGrayColor];
    cell.backgroundColor=[UIColor clearColor];
    
    if([title isEqualToString:@"老板模式"])
    {
        cell.accessoryView=bossswitch;
    }
    else cell.accessoryType   =  UITableViewCellAccessoryDisclosureIndicator;

    return cell;
    
    
}


@end
